<template>
  <div>
    <indexNumberItem :formItem="compConfig" :formNamePath="props.formNamePath"></indexNumberItem>
  </div>
</template>

<script lang="ts" setup>
import { ref, computed, nextTick, onMounted } from "vue"
import indexNumberItem from "../../formitem/indexNumber/index.vue"
import formItemForm from './config';
import { useColumnModel } from '@/components/draggable/hooks/useColumnModel';
import request from "@/api/index";

const props = defineProps({
  element: [],
  formNamePath: [],
})


const compConfig = ref(JSON.parse(JSON.stringify(formItemForm.component.settings)));
useColumnModel(compConfig, computed(() => props.element))
const fetchWorkflowList = async () => {
  let params1 = {
    type: 1,
  };
  let data1 = await request.fetchIndexNumberList(params1);
  data1.forEach((item: any) => {
    item.label = item.name;
    item.value = item.id;
  });
  let params2 = {
    type: 2,
  };
  let data2 = await request.fetchIndexNumberList(params2);
  data2.forEach((item: any) => {
    item.label = item.name;
    item.value = item.id;
  });
  let params3 = {
    type: 3,
  };
  let data3 = await request.fetchIndexNumberList(params3);
  data3.forEach((item: any) => {
    item.label = item.name;
    item.value = item.id;
  });
  nextTick(() => {
    compConfig.value.basicOption = data1;
    compConfig.value.topicOption = data2;
    compConfig.value.codeOption = data3;
  });

  // modelData.value.options = data;
};
onMounted(() => {
  fetchWorkflowList();
});

</script>

<style lang="less" scoped></style>